<div class="{{$viewClass['form-group']}} {!! !$errors->has($errorKey) ? '' : 'has-error' !!}">

    <label for="{{$id}}" class="{{$viewClass['label']}} control-label">{{$label}}</label>

    <div class="{{$viewClass['field']}}">

        @include('admin::form.error')

        <select class="form-control {{$class}}" style="width: 100%;" name="{{$name}}[]" multiple="multiple" data-placeholder="{{ $placeholder }}" {!! $attributes !!} >
            @foreach($options as $select => $option)
                <option value="{{$option['id']}}" data-url="{{$option['url']}}" {{ $option['id'] == old($column, $value) ?'selected':'' }}>{{$option['title']}}</option>
            @endforeach
        </select>
        <input type="hidden" name="{{$name}}[]" />

        @include('admin::form.help-block')

    </div>
</div>
<script>
  $(function(){
    let classname = "{{$class}}"
    $('.'+classname).select2({
      allowClear:true,
      placeholder:{id:'', text:"{{$label}}"},
      templateResult: function(result){
        console.log($(result.element).data('url'))
        var markup = $('<span></span>')
        markup.append('<img src="' + $(result.element).data('url') + '" style="width: 15%; class="img-flag"/>')
        markup.append(result.text)
        return markup
      }
    })
  })
</script>
